package com.yunhe.control;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.ws.Response;

import com.yun.dao.AddMainDao;
import com.yunhe.bean.Admin;
import com.yunhe.service.AdminService;

/**
 * Servlet implementation class SubmitAdmin
 */
@WebServlet("/submitadmin")
public class SubmitAdmin extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public SubmitAdmin() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		String aname=request.getParameter("username");
		String apass=request.getParameter("pass");
		String tel=request.getParameter("phone");
		String email=request.getParameter("email");
		Admin admin = new Admin();
		admin.setAname(aname);
		admin.setApass(apass);
		admin.setEmail(email);
		admin.setTel(tel);
		AdminService ads =new AdminService();
		int a =ads.submitAdmin(admin);
		PrintWriter pw =response.getWriter();
		if(a>0){
			request.getRequestDispatcher("adminlist").forward(request, response);
			
		}else{
			
		}
		
	}
	

}
